package com.atlyc.common.dto;

/**
 * 
 * 返回对象工厂
 * 
 * @author lyc
 *
 */
public class ReturnResultFactory {

    public static ReturnResult success(String message) {
        return new ReturnResult(ReturnResultCode.SUCCESS.getCode(), message);
    }

    public static ReturnResult success(String message, Object data) {
        //ReflectUtils.convertNullToDefault(data);
        return new ReturnResult(ReturnResultCode.SUCCESS.getCode(), message, data);
    }

    public static ReturnResult exceptionFail(String message) {
        return new ReturnResult(ReturnResultCode.FAIL_EXCEPTION.getCode(), message);
    }

    public static ReturnResult exceptionFail(String message, Object data) {
        //ReflectUtils.convertNullToDefault(data);
        return new ReturnResult(ReturnResultCode.FAIL_EXCEPTION.getCode(), message, data);
    }

    public static ReturnResult authorityFail(String message) {
        return new ReturnResult(ReturnResultCode.FAIL_AUTHORITY.getCode(), message);
    }

    public static ReturnResult authorityFail(String message, Object data) {
        //ReflectUtils.convertNullToDefault(data);
        return new ReturnResult(ReturnResultCode.FAIL_AUTHORITY.getCode(), message, data);
    }

    public static ReturnResult fieldFail(String message) {
        return new ReturnResult(ReturnResultCode.FAIL_FIELD.getCode(), message);
    }

    public static ReturnResult fieldFail(String message, Object data) {
        //ReflectUtils.convertNullToDefault(data);
        return new ReturnResult(ReturnResultCode.FAIL_FIELD.getCode(), message, data);
    }

    public static ReturnResult other(int code, String message) {
        return new ReturnResult(code, message);
    }

    public static ReturnResult other(int code, String message, Object data) {
        //ReflectUtils.convertNullToDefault(data);
        return new ReturnResult(code, message, data);
    }

    /*public static String successStr(String message, Object data) {
        ReturnResult result = new ReturnResult(ReturnResultCode.SUCCESS.getCode(), message, data);
        return GsonUtils.toJson(result);
    }*/

}
